package com.sample.springbatch.job.sample.reader;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.item.file.MultiResourceItemReader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * Flat文件格式读取类  实现了分隔符和json格式
 * Created by zwg on 2017/8/8.
 */
@Component
public class RepayOrderMultiResourceFlatFileItemReader<T> extends MultiResourceItemReader {

    Logger logger = LoggerFactory.getLogger(RepayOrderMultiResourceFlatFileItemReader.class);

    @Autowired
    RepayOrderFlatFileItemReader repayOrderFlatFileItemReader;

    public RepayOrderMultiResourceFlatFileItemReader() {
        setStrict(false); //文件不存在抛异常
        setResources(new Resource[]{new ClassPathResource("jobdata/repay-orders-multi-1.dat"),
                new ClassPathResource("jobdata/repay-orders-multi-2.dat")});

    }

    @PostConstruct
    public void init(){
        setDelegate(repayOrderFlatFileItemReader);
    }
}
